package presentation;

import javax.swing.JFrame;

import vo.UserVO;

public class LoginModel {
	
	private LoginFrame loginFrame;
	
	public LoginModel(JFrame frame) {
		loginFrame = new LoginFrame();
		loginFrame.setLocationRelativeTo(frame);
		loginFrame.setVisible(true);
	}
	
	public UserVO getUserVO() {
		while (true) {
			try {
				Thread.sleep(50);
			} catch (Exception e) {
				e.printStackTrace();
			}
			
			DialogEvent event = loginFrame.getEvent();
			if (event == null) {
				continue;
			}
			if (event == DialogEvent.CANCEL) {
				return null;
			}
			if (event == DialogEvent.CONFIRM) {
				return loginFrame.getUserVO();
			}
		}
	}

	public void disposeFrame() {
		loginFrame.dispose();
	}

}
